package com.wecan.oauth.controller;

import com.wecan.oauth.DTO.security.ListByPMarkDTO;
import com.wecan.base.controller.BaseController;
import com.wecan.base.metadata.PermissionTree;
import com.wecan.base.metadata.PermissionUtils;
import com.wecan.base.model.Result;
import com.wecan.cache.annotation.AccessLimit;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author liuzhihao
 * @Date 2022.01.20
 * @Version ${version}
 * @Description ${description}
 */
@Tag(name = "权限接口")
@RestController
@RequestMapping(value = "/permission")
public class PermissionController extends BaseController {

    @Operation(summary = "获取所有权限", description = "获取所有权限",
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(content = @Content(mediaType = "application/json")),
            responses = {@ApiResponse(description = "获取所有权限", content = @Content(mediaType = "application/json"))})
    @AccessLimit
    @PostMapping(value = "/listall")
    public Result getAllPermission() {
        List<PermissionTree> permissionTrees = PermissionUtils.permissionTrees;
        return Result.content(permissionTrees);
    }
}
